
const app = getApp()

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    count: 0,
    Name:'',
    textarea: "这里放你个人的简介！",
    http: "",
    phone: "",
    imgs: "/images/timg.jpg ",
    inputValue: [{
      icon: "/images/shouji.png ",
      title: "手机：",
      value: "",
    },
    {
      icon: "/images/weixin.png ",
      title: "微信：",
      value: "",
    },
    {
      icon: "/images/youxiang.png ",
      title: "邮箱：",
      value: "",
    },
    {
      icon: "/images/dizhi.png ",
      title: "地址：",
      value: "",
    },
    ],
    app: app.globalData.Post,
    // 是否收藏
    isCollect: false,
    code:0
  },

  // my主页
  my: function () {
    wx.navigateTo({
      url: '../index/index',
    })
  },
  // 电话薄页
  phone: function () {
    wx.navigateTo({
      url: '../phone/phone',
    })
  },
  // 二维码面
  ma: function () {
    wx.navigateTo({
      url: '../Others-card/Others-card'
    })
  },
  // 点击收藏
  collect:function(){
    app.postData2('user/collect', {}, res => {
      this.setData({
        code:res.data.code
      })
      console.log('7.收藏、取消收藏他人卡片');
      console.log(res);
      // 提示
      wx.showToast({
        title: this.data.code != 0 ? '收藏成功' : '取消收藏',
        icon: 'success'
      })
      // 缓存到本地数据
      wx.getStorage({
        key: 'id7',
        data: res.data.data,
      })   
    })
  },

  onLoad: function (options) { 
    // 接口6
    app.postData2('user/searchOther', {}, res => {
      var userData1 = res.data.data
      this.setData({
        userData: res.data.data,
        Name: userData1.name,
        'inputValue[0].value': userData1.tel,
        'inputValue[1].value': userData1.wechat,
        'inputValue[2].value': userData1.email,
        'inputValue[3].value': userData1.city,
      })
      console.log('6.查询别人card');
      console.log(res);     
    })

    //   // 接口6
    //    wx.request({
    //      url: app.ReqUrl +'user/searchOther',
    //   data: {
    //     'openid_key': app.openid_key,
    //     'openid': 'oIxOZ5UvNRnUCxIsJ2EUVg6LVfDA'
    //   },
    //   header: {
    //     'content-type': 'application/x-www-form-urlencoded',
    //     'Cookie': 'PHPSESSID=' + app.Cookie + ';path=/'
    //   },
    //   method: 'POST',
    //   dataType: 'json',
    //   responseType: 'text',
    //   success: function(res) {
    //     console.log('hahahah');
    //     console.log(res)
    //   },
    // })
  },
  getUserInfo: function (e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
})